package org.cli.admin.cli;

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

import org.cli.admin.cli.printer.ConsolePrinter;
import org.cli.admin.command.ICommand;

import com.google.inject.Inject;

/**
 * Listens the user input and performs a Command execution.
 *
 * @see ICommand
 */
public class CLIManager {
    
    private Executor executor;
    
    @Inject
	private CLIListener listener;
    
    @Inject
    private ConsolePrinter printer;

    public CLIManager() {
        executor = Executors.newSingleThreadExecutor();
    }

    public void listen() {
    	printer.printGreeting();
        
        initCLIListener();
    }

    /**
     * Start in parallel thread - we should release the method listen()
     */
    private void initCLIListener() {
        executor.execute(listener);
    }

}